/******/ (() => { // webpackBootstrap
/******/ 	"use strict";
/******/ 	var __webpack_modules__ = ({

/***/ "./apps/ms-file/config/index.ts":
/*!**************************************!*\
  !*** ./apps/ms-file/config/index.ts ***!
  \**************************************/
/***/ ((__unused_webpack_module, exports) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
const envMap = {
    dev: {
        serviceId: "file_1",
        serviceName: 'file',
        port: 3002,
        ip: '127.0.0.1',
        dir: "./uploads"
    },
    test: {
        serviceId: "file_1",
        serviceName: 'file',
        port: 3002,
        ip: '127.0.0.1',
        dir: "./uploads"
    },
    prod: {
        serviceId: "file_1",
        serviceName: 'file',
        port: 3002,
        ip: '127.0.0.1',
        dir: "./uploads"
    }
};
const env = process.env.NODE_ENV.trim();
const config = envMap[env];
exports["default"] = config;


/***/ }),

/***/ "./apps/ms-file/config/remote/db.ts":
/*!******************************************!*\
  !*** ./apps/ms-file/config/remote/db.ts ***!
  \******************************************/
/***/ ((__unused_webpack_module, exports) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
const envMap = {
    dev: {
        host: 'localhost',
        port: 3306,
        password: '123456',
        username: 'root',
        database: 'hnblogdb',
    },
    test: {
        host: 'localhost',
        port: 3306,
        password: '123456',
        username: 'root',
        database: 'hnblogdb',
    },
    prod: {
        host: 'localhost',
        port: 3306,
        password: '123456',
        username: 'root',
        database: 'hnblogdb',
    },
};
const config = envMap[process.env.NODE_ENV.trim()];
exports["default"] = config;


/***/ }),

/***/ "./apps/ms-file/src/api/auth.api.ts":
/*!******************************************!*\
  !*** ./apps/ms-file/src/api/auth.api.ts ***!
  \******************************************/
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
const common_1 = __webpack_require__(/*! @nestjs/common */ "@nestjs/common");
const nacosNamingClient_service_1 = __webpack_require__(/*! libs/nacos/nacosNamingClient.service */ "./libs/nacos/src/nacosNamingClient.service.ts");
const actionBuilder_1 = __webpack_require__(/*! libs/common/utils/actionBuilder */ "./libs/common/src/utils/actionBuilder.ts");
let AuthApi = class AuthApi {
    constructor(nacosNamingClientService) {
        this.nacosNamingClientService = nacosNamingClientService;
        this.action = (0, actionBuilder_1.default)({
            timeout: 30 * 1000
        });
    }
    async getAuthOneHostPath() {
        const host = await this.nacosNamingClientService.selectOneInstances({
            serviceName: 'auth',
        });
        const path = 'http://' + host.ip + ':' + host.port;
        return path;
    }
    async validateIdentity(data) {
        const path = await this.getAuthOneHostPath();
        return await this.action({
            method: 'POST',
            url: '/auth/validateIdentity',
            data: data,
            baseURL: path
        });
    }
};
AuthApi = __decorate([
    (0, common_1.Injectable)(),
    __metadata("design:paramtypes", [typeof (_a = typeof nacosNamingClient_service_1.NacosNamingClientService !== "undefined" && nacosNamingClient_service_1.NacosNamingClientService) === "function" ? _a : Object])
], AuthApi);
exports["default"] = AuthApi;


/***/ }),

/***/ "./apps/ms-file/src/controller/file.controller.ts":
/*!********************************************************!*\
  !*** ./apps/ms-file/src/controller/file.controller.ts ***!
  \********************************************************/
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a, _b, _c, _d;
Object.defineProperty(exports, "__esModule", ({ value: true }));
const common_1 = __webpack_require__(/*! @nestjs/common */ "@nestjs/common");
const fs = __webpack_require__(/*! fs */ "fs");
const express_1 = __webpack_require__(/*! express */ "express");
const file_service_1 = __webpack_require__(/*! ../service/file.service */ "./apps/ms-file/src/service/file.service.ts");
const R_1 = __webpack_require__(/*! libs/common/utils/R */ "./libs/common/src/utils/R.ts");
const platform_express_1 = __webpack_require__(/*! @nestjs/platform-express */ "@nestjs/platform-express");
const multer_1 = __webpack_require__(/*! multer */ "multer");
const path_1 = __webpack_require__(/*! path */ "path");
const config_1 = __webpack_require__(/*! ../../config */ "./apps/ms-file/config/index.ts");
const crypto_1 = __webpack_require__(/*! crypto */ "crypto");
const BusinessError_1 = __webpack_require__(/*! libs/common/utils/BusinessError */ "./libs/common/src/utils/BusinessError.ts");
let FileController = class FileController {
    constructor(fileService) {
        this.fileService = fileService;
    }
    async uploadFile(request, file) {
        const uri = 'http://127.0.0.1:' + config_1.default.port;
        return R_1.default.ok(uri + '/file/' + file.filename);
    }
    async delFile(fileName) {
        const path = config_1.default.dir + '/' + fileName;
        if (!fs.existsSync(path)) {
            throw new BusinessError_1.default('文件未找到！', common_1.HttpStatus.NOT_FOUND);
        }
        fs.unlinkSync(path);
        return R_1.default.ok();
    }
    async readFile(fileName, res) {
        const path = config_1.default.dir + '/' + fileName;
        if (!fs.existsSync(path)) {
            throw new BusinessError_1.default('文件未找到！', common_1.HttpStatus.NOT_FOUND);
        }
        res.setHeader('Content-disposition', `attachment; filename=${fileName}`);
        const readStream = fs.createReadStream(path);
        readStream.pipe(res);
        readStream.on('error', (err) => {
            throw new BusinessError_1.default('读取文件失败！', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
        });
        readStream.on('end', () => {
            console.log('文件传输完成');
        });
    }
};
__decorate([
    (0, common_1.Post)('/upload'),
    (0, common_1.UseInterceptors)((0, platform_express_1.FileInterceptor)('file', {
        storage: (0, multer_1.diskStorage)({
            destination: config_1.default.dir,
            filename: function (req, file, cb) {
                cb(null, (0, crypto_1.randomUUID)() + (0, path_1.extname)(file.originalname));
            },
        }),
    })),
    __param(0, (0, common_1.Request)()),
    __param(1, (0, common_1.UploadedFile)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, Object]),
    __metadata("design:returntype", typeof (_b = typeof Promise !== "undefined" && Promise) === "function" ? _b : Object)
], FileController.prototype, "uploadFile", null);
__decorate([
    (0, common_1.Post)('/delete/:fileName'),
    __param(0, (0, common_1.Param)('fileName')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String]),
    __metadata("design:returntype", typeof (_c = typeof Promise !== "undefined" && Promise) === "function" ? _c : Object)
], FileController.prototype, "delFile", null);
__decorate([
    (0, common_1.Get)('/:fileName'),
    __param(0, (0, common_1.Param)('fileName')),
    __param(1, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, typeof (_d = typeof express_1.Response !== "undefined" && express_1.Response) === "function" ? _d : Object]),
    __metadata("design:returntype", Promise)
], FileController.prototype, "readFile", null);
FileController = __decorate([
    (0, common_1.Controller)('/file'),
    __metadata("design:paramtypes", [typeof (_a = typeof file_service_1.default !== "undefined" && file_service_1.default) === "function" ? _a : Object])
], FileController);
exports["default"] = FileController;


/***/ }),

/***/ "./apps/ms-file/src/entity/file.entity.ts":
/*!************************************************!*\
  !*** ./apps/ms-file/src/entity/file.entity.ts ***!
  \************************************************/
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const typeorm_1 = __webpack_require__(/*! typeorm */ "typeorm");
let File = class File {
};
__decorate([
    (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
    __metadata("design:type", String)
], File.prototype, "id", void 0);
__decorate([
    (0, typeorm_1.Column)('varchar'),
    __metadata("design:type", String)
], File.prototype, "name", void 0);
__decorate([
    (0, typeorm_1.Column)('varchar'),
    __metadata("design:type", String)
], File.prototype, "path", void 0);
__decorate([
    (0, typeorm_1.CreateDateColumn)(),
    __metadata("design:type", String)
], File.prototype, "createTime", void 0);
__decorate([
    (0, typeorm_1.UpdateDateColumn)(),
    __metadata("design:type", String)
], File.prototype, "updateTime", void 0);
__decorate([
    (0, typeorm_1.VersionColumn)(),
    __metadata("design:type", Number)
], File.prototype, "version", void 0);
File = __decorate([
    (0, typeorm_1.Entity)({
        name: 't_file',
    })
], File);
exports["default"] = File;


/***/ }),

/***/ "./apps/ms-file/src/interceptor/auth.interceptor.ts":
/*!**********************************************************!*\
  !*** ./apps/ms-file/src/interceptor/auth.interceptor.ts ***!
  \**********************************************************/
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
const common_1 = __webpack_require__(/*! @nestjs/common */ "@nestjs/common");
const auth_api_1 = __webpack_require__(/*! ../api/auth.api */ "./apps/ms-file/src/api/auth.api.ts");
let AuthInterceptor = class AuthInterceptor {
    async intercept(context, next) {
        const request = context.switchToHttp().getRequest();
        const token = request.headers['token'];
        const urlParts = request.url.split('/');
        await this.authApi.validateIdentity({
            token,
            service: urlParts[1],
            api: '/' + urlParts.slice(2).join('/'),
        });
        return next.handle();
    }
};
__decorate([
    (0, common_1.Inject)(auth_api_1.default),
    __metadata("design:type", typeof (_a = typeof auth_api_1.default !== "undefined" && auth_api_1.default) === "function" ? _a : Object)
], AuthInterceptor.prototype, "authApi", void 0);
AuthInterceptor = __decorate([
    (0, common_1.Injectable)()
], AuthInterceptor);
exports["default"] = AuthInterceptor;


/***/ }),

/***/ "./apps/ms-file/src/ms-file.module.ts":
/*!********************************************!*\
  !*** ./apps/ms-file/src/ms-file.module.ts ***!
  \********************************************/
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.MsFileModule = void 0;
const common_1 = __webpack_require__(/*! @nestjs/common */ "@nestjs/common");
const typeorm_1 = __webpack_require__(/*! @nestjs/typeorm */ "@nestjs/typeorm");
const db_1 = __webpack_require__(/*! ../config/remote/db */ "./apps/ms-file/config/remote/db.ts");
const config_1 = __webpack_require__(/*! ../config */ "./apps/ms-file/config/index.ts");
const file_entity_1 = __webpack_require__(/*! ./entity/file.entity */ "./apps/ms-file/src/entity/file.entity.ts");
const file_controller_1 = __webpack_require__(/*! ./controller/file.controller */ "./apps/ms-file/src/controller/file.controller.ts");
const file_service_1 = __webpack_require__(/*! ./service/file.service */ "./apps/ms-file/src/service/file.service.ts");
const platform_express_1 = __webpack_require__(/*! @nestjs/platform-express */ "@nestjs/platform-express");
const nacos_module_1 = __webpack_require__(/*! libs/nacos/nacos.module */ "./libs/nacos/src/nacos.module.ts");
const nacos_1 = __webpack_require__(/*! config/nacos */ "./config/nacos.ts");
const nacosNamingClient_service_1 = __webpack_require__(/*! libs/nacos/nacosNamingClient.service */ "./libs/nacos/src/nacosNamingClient.service.ts");
const auth_interceptor_1 = __webpack_require__(/*! ./interceptor/auth.interceptor */ "./apps/ms-file/src/interceptor/auth.interceptor.ts");
const auth_api_1 = __webpack_require__(/*! ./api/auth.api */ "./apps/ms-file/src/api/auth.api.ts");
let MsFileModule = class MsFileModule {
    constructor(nacosNamingClientService) {
        this.nacosNamingClientService = nacosNamingClientService;
        nacosNamingClientService.registerInstance({
            serviceName: config_1.default.serviceName,
            groupName: 'DEFAULT_GROUP',
            instance: {
                ip: config_1.default.ip,
                port: config_1.default.port,
                instanceId: config_1.default.serviceId,
                healthy: true,
                enabled: true,
            }
        });
    }
};
exports.MsFileModule = MsFileModule;
exports.MsFileModule = MsFileModule = __decorate([
    (0, common_1.Module)({
        imports: [
            platform_express_1.MulterModule.register({
                dest: config_1.default.dir,
            }),
            typeorm_1.TypeOrmModule.forRoot({
                type: 'mysql',
                host: db_1.default.host,
                port: db_1.default.port,
                username: db_1.default.username,
                password: db_1.default.password,
                database: db_1.default.database,
                entities: [file_entity_1.default],
                synchronize: true,
            }),
            typeorm_1.TypeOrmModule.forFeature([file_entity_1.default]),
            nacos_module_1.NacosModule.forRoot({
                clientOptions: {
                    serverAddr: nacos_1.default.url,
                    namespace: nacos_1.default.namespace,
                },
                nacosNamingClientConfig: {
                    logger: console,
                    serverList: nacos_1.default.url,
                    namespace: nacos_1.default.namespace,
                }
            })
        ],
        controllers: [file_controller_1.default],
        providers: [file_service_1.default, auth_api_1.default, auth_interceptor_1.default],
    }),
    __metadata("design:paramtypes", [typeof (_a = typeof nacosNamingClient_service_1.NacosNamingClientService !== "undefined" && nacosNamingClient_service_1.NacosNamingClientService) === "function" ? _a : Object])
], MsFileModule);


/***/ }),

/***/ "./apps/ms-file/src/service/file.service.ts":
/*!**************************************************!*\
  !*** ./apps/ms-file/src/service/file.service.ts ***!
  \**************************************************/
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const common_1 = __webpack_require__(/*! @nestjs/common */ "@nestjs/common");
let FileService = class FileService {
    constructor() { }
};
FileService = __decorate([
    (0, common_1.Injectable)(),
    __metadata("design:paramtypes", [])
], FileService);
exports["default"] = FileService;


/***/ }),

/***/ "./config/nacos.ts":
/*!*************************!*\
  !*** ./config/nacos.ts ***!
  \*************************/
/***/ ((__unused_webpack_module, exports) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
const envMap = {
    dev: {
        url: '127.0.0.1:8848',
        namespace: '95f2c1a6-1b05-4e86-af07-e409e492bfc9',
    },
    test: {
        url: '',
        namespace: '',
    },
    prod: {
        url: '',
        namespace: '',
    },
};
const config = envMap[process.env.NODE_ENV.trim()];
exports["default"] = config;


/***/ }),

/***/ "./libs/common/src/filters/GlobalException.filter.ts":
/*!***********************************************************!*\
  !*** ./libs/common/src/filters/GlobalException.filter.ts ***!
  \***********************************************************/
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var GlobalExceptionFilter_1;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.GlobalExceptionFilter = void 0;
const common_1 = __webpack_require__(/*! @nestjs/common */ "@nestjs/common");
const logger_service_1 = __webpack_require__(/*! @nestjs/common/services/logger.service */ "@nestjs/common/services/logger.service");
const BusinessError_1 = __webpack_require__(/*! libs/common/utils/BusinessError */ "./libs/common/src/utils/BusinessError.ts");
let GlobalExceptionFilter = GlobalExceptionFilter_1 = class GlobalExceptionFilter {
    constructor() {
        this.logger = new logger_service_1.Logger(GlobalExceptionFilter_1.name);
    }
    catch(exception, host) {
        const ctx = host.switchToHttp();
        const response = ctx.getResponse();
        const request = ctx.getRequest();
        let message = exception?.message ||
            (Array.isArray(exception?.response?.message) ?
                (exception?.response?.message.join &&
                    exception?.response?.message?.join(','))
                : exception?.response?.message) || 'Internal server error';
        console.log('<<<<<<<<<<<<<');
        this.logger.error(new Date());
        this.logger.error(request.url);
        this.logger.error(message);
        console.log('>>>>>>>>>>>>>>');
        let status = common_1.HttpStatus.INTERNAL_SERVER_ERROR;
        if (exception instanceof common_1.HttpException) {
            status = exception.getStatus();
            if (exception instanceof common_1.BadRequestException) {
                status = exception.getStatus();
            }
        }
        else if (exception instanceof BusinessError_1.default) {
            status = exception.code;
        }
        response.status(common_1.HttpStatus.OK).json({
            code: status,
            timestamp: new Date(),
            path: request.url,
            message,
        });
    }
};
exports.GlobalExceptionFilter = GlobalExceptionFilter;
exports.GlobalExceptionFilter = GlobalExceptionFilter = GlobalExceptionFilter_1 = __decorate([
    (0, common_1.Catch)()
], GlobalExceptionFilter);


/***/ }),

/***/ "./libs/common/src/utils/BusinessError.ts":
/*!************************************************!*\
  !*** ./libs/common/src/utils/BusinessError.ts ***!
  \************************************************/
/***/ ((__unused_webpack_module, exports) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
class BusinessError extends Error {
    constructor(message = '服务端错误！', code = 500) {
        super(message);
        this.name = this.constructor.name;
        this.code = code;
        Error.captureStackTrace(this, BusinessError);
    }
}
exports["default"] = BusinessError;


/***/ }),

/***/ "./libs/common/src/utils/R.ts":
/*!************************************!*\
  !*** ./libs/common/src/utils/R.ts ***!
  \************************************/
/***/ ((__unused_webpack_module, exports) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
class R {
    constructor(options) {
        this.code = options.code;
        this.message = options.message;
        this.data = options?.data;
    }
    static ok(data) {
        return new R({
            code: 200,
            message: '请求成功！',
            data,
        });
    }
    static error(message) {
        return new R({
            code: 500,
            message,
        });
    }
}
exports["default"] = R;


/***/ }),

/***/ "./libs/common/src/utils/actionBuilder.ts":
/*!************************************************!*\
  !*** ./libs/common/src/utils/actionBuilder.ts ***!
  \************************************************/
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
const common_1 = __webpack_require__(/*! @nestjs/common */ "@nestjs/common");
const axios_1 = __webpack_require__(/*! axios */ "axios");
const actionBuilder = (axiosConfig) => {
    const action = axios_1.default.create(axiosConfig);
    action.interceptors.request.use((config) => {
        return config;
    }, (error) => {
        return Promise.reject(error);
    });
    action.interceptors.response.use((res) => {
        if (res.status == common_1.HttpStatus.OK) {
            if (res.data.code === 200) {
                return Promise.resolve(res.data.data);
            }
            return Promise.reject(res.data.message);
        }
        return Promise.reject(res);
    }, (error) => {
        return Promise.reject(error);
    });
    return action.request;
};
exports["default"] = actionBuilder;


/***/ }),

/***/ "./libs/nacos/src/nacos.module.ts":
/*!****************************************!*\
  !*** ./libs/nacos/src/nacos.module.ts ***!
  \****************************************/
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var NacosModule_1;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.NacosModule = void 0;
const common_1 = __webpack_require__(/*! @nestjs/common */ "@nestjs/common");
const nacosNamingClient_service_1 = __webpack_require__(/*! ./nacosNamingClient.service */ "./libs/nacos/src/nacosNamingClient.service.ts");
const nacosConfigClient_service_1 = __webpack_require__(/*! ./nacosConfigClient.service */ "./libs/nacos/src/nacosConfigClient.service.ts");
const nacos_1 = __webpack_require__(/*! nacos */ "nacos");
let NacosModule = NacosModule_1 = class NacosModule {
    static forRoot(options) {
        const providers = [
            {
                provide: 'NacosOptions',
                useValue: options,
            },
            {
                provide: 'NacosConfigClient',
                useFactory: (options) => {
                    return new nacos_1.NacosConfigClient(options.clientOptions);
                },
                inject: ['NacosOptions'],
            },
            {
                provide: 'NacosNamingClient',
                useFactory: (options) => {
                    return new nacos_1.NacosNamingClient(options.nacosNamingClientConfig);
                },
                inject: ['NacosOptions'],
            },
            nacosConfigClient_service_1.NacosConfigClientService,
            nacosNamingClient_service_1.NacosNamingClientService,
        ];
        return {
            module: NacosModule_1,
            providers,
            exports: [
                'NacosConfigClient',
                'NacosNamingClient',
                nacosConfigClient_service_1.NacosConfigClientService,
                nacosNamingClient_service_1.NacosNamingClientService,
            ],
        };
    }
};
exports.NacosModule = NacosModule;
exports.NacosModule = NacosModule = NacosModule_1 = __decorate([
    (0, common_1.Module)({
        providers: [nacosConfigClient_service_1.NacosConfigClientService, nacosNamingClient_service_1.NacosNamingClientService],
        exports: [nacosConfigClient_service_1.NacosConfigClientService, nacosNamingClient_service_1.NacosNamingClientService],
    })
], NacosModule);


/***/ }),

/***/ "./libs/nacos/src/nacosConfigClient.service.ts":
/*!*****************************************************!*\
  !*** ./libs/nacos/src/nacosConfigClient.service.ts ***!
  \*****************************************************/
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.NacosConfigClientService = void 0;
const common_1 = __webpack_require__(/*! @nestjs/common */ "@nestjs/common");
const nacos_1 = __webpack_require__(/*! nacos */ "nacos");
let NacosConfigClientService = class NacosConfigClientService {
    constructor(nacosConfigClient) {
        this.nacosConfigClient = nacosConfigClient;
    }
    async getConfig(dataId, group, options) {
        try {
            const data = await this.nacosConfigClient.getConfig(dataId, group, options);
            return JSON.parse(data);
        }
        catch (e) {
            return null;
        }
    }
};
exports.NacosConfigClientService = NacosConfigClientService;
exports.NacosConfigClientService = NacosConfigClientService = __decorate([
    (0, common_1.Injectable)(),
    __param(0, (0, common_1.Inject)('NacosConfigClient')),
    __metadata("design:paramtypes", [typeof (_a = typeof nacos_1.NacosConfigClient !== "undefined" && nacos_1.NacosConfigClient) === "function" ? _a : Object])
], NacosConfigClientService);


/***/ }),

/***/ "./libs/nacos/src/nacosNamingClient.service.ts":
/*!*****************************************************!*\
  !*** ./libs/nacos/src/nacosNamingClient.service.ts ***!
  \*****************************************************/
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.NacosNamingClientService = void 0;
const common_1 = __webpack_require__(/*! @nestjs/common */ "@nestjs/common");
const nacos_1 = __webpack_require__(/*! nacos */ "nacos");
const weightedRandomSelect_1 = __webpack_require__(/*! ./utils/weightedRandomSelect */ "./libs/nacos/src/utils/weightedRandomSelect.ts");
let NacosNamingClientService = class NacosNamingClientService {
    constructor(nacosNamingClient) {
        this.nacosNamingClient = nacosNamingClient;
    }
    async getClient() {
        return this.nacosNamingClient;
    }
    async selectOneInstances(options) {
        const hosts = await this.nacosNamingClient.selectInstances(options.serviceName, options.groupName, options.clusters, options.healthy, options.subscribe);
        const host = (0, weightedRandomSelect_1.default)(hosts);
        return host;
    }
    async registerInstance(options) {
        await this.nacosNamingClient.registerInstance(options.serviceName, options.instance, options?.groupName);
        return this.nacosNamingClient;
    }
};
exports.NacosNamingClientService = NacosNamingClientService;
exports.NacosNamingClientService = NacosNamingClientService = __decorate([
    (0, common_1.Injectable)(),
    __param(0, (0, common_1.Inject)('NacosNamingClient')),
    __metadata("design:paramtypes", [typeof (_a = typeof nacos_1.NacosNamingClient !== "undefined" && nacos_1.NacosNamingClient) === "function" ? _a : Object])
], NacosNamingClientService);


/***/ }),

/***/ "./libs/nacos/src/utils/weightedRandomSelect.ts":
/*!******************************************************!*\
  !*** ./libs/nacos/src/utils/weightedRandomSelect.ts ***!
  \******************************************************/
/***/ ((__unused_webpack_module, exports) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
function weightedRandomSelect(items) {
    if (items.length === 0) {
        return null;
    }
    let totalWeight = items.reduce((acc, item) => acc + item.weight, 0);
    const randomWeight = Math.random() * totalWeight;
    let currentWeight = 0;
    for (const item of items) {
        currentWeight += item.weight;
        if (currentWeight >= randomWeight) {
            return item;
        }
    }
    return items[items.length - 1];
}
exports["default"] = weightedRandomSelect;


/***/ }),

/***/ "@nestjs/common":
/*!*********************************!*\
  !*** external "@nestjs/common" ***!
  \*********************************/
/***/ ((module) => {

module.exports = require("@nestjs/common");

/***/ }),

/***/ "@nestjs/common/services/logger.service":
/*!*********************************************************!*\
  !*** external "@nestjs/common/services/logger.service" ***!
  \*********************************************************/
/***/ ((module) => {

module.exports = require("@nestjs/common/services/logger.service");

/***/ }),

/***/ "@nestjs/core":
/*!*******************************!*\
  !*** external "@nestjs/core" ***!
  \*******************************/
/***/ ((module) => {

module.exports = require("@nestjs/core");

/***/ }),

/***/ "@nestjs/platform-express":
/*!*******************************************!*\
  !*** external "@nestjs/platform-express" ***!
  \*******************************************/
/***/ ((module) => {

module.exports = require("@nestjs/platform-express");

/***/ }),

/***/ "@nestjs/typeorm":
/*!**********************************!*\
  !*** external "@nestjs/typeorm" ***!
  \**********************************/
/***/ ((module) => {

module.exports = require("@nestjs/typeorm");

/***/ }),

/***/ "axios":
/*!************************!*\
  !*** external "axios" ***!
  \************************/
/***/ ((module) => {

module.exports = require("axios");

/***/ }),

/***/ "express":
/*!**************************!*\
  !*** external "express" ***!
  \**************************/
/***/ ((module) => {

module.exports = require("express");

/***/ }),

/***/ "multer":
/*!*************************!*\
  !*** external "multer" ***!
  \*************************/
/***/ ((module) => {

module.exports = require("multer");

/***/ }),

/***/ "nacos":
/*!************************!*\
  !*** external "nacos" ***!
  \************************/
/***/ ((module) => {

module.exports = require("nacos");

/***/ }),

/***/ "typeorm":
/*!**************************!*\
  !*** external "typeorm" ***!
  \**************************/
/***/ ((module) => {

module.exports = require("typeorm");

/***/ }),

/***/ "crypto":
/*!*************************!*\
  !*** external "crypto" ***!
  \*************************/
/***/ ((module) => {

module.exports = require("crypto");

/***/ }),

/***/ "fs":
/*!*********************!*\
  !*** external "fs" ***!
  \*********************/
/***/ ((module) => {

module.exports = require("fs");

/***/ }),

/***/ "path":
/*!***********************!*\
  !*** external "path" ***!
  \***********************/
/***/ ((module) => {

module.exports = require("path");

/***/ })

/******/ 	});
/************************************************************************/
/******/ 	// The module cache
/******/ 	var __webpack_module_cache__ = {};
/******/ 	
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/ 		// Check if module is in cache
/******/ 		var cachedModule = __webpack_module_cache__[moduleId];
/******/ 		if (cachedModule !== undefined) {
/******/ 			return cachedModule.exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = __webpack_module_cache__[moduleId] = {
/******/ 			// no module.id needed
/******/ 			// no module.loaded needed
/******/ 			exports: {}
/******/ 		};
/******/ 	
/******/ 		// Execute the module function
/******/ 		__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ 	
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/ 	
/************************************************************************/
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
(() => {
var exports = __webpack_exports__;
/*!**********************************!*\
  !*** ./apps/ms-file/src/main.ts ***!
  \**********************************/

Object.defineProperty(exports, "__esModule", ({ value: true }));
const core_1 = __webpack_require__(/*! @nestjs/core */ "@nestjs/core");
const ms_file_module_1 = __webpack_require__(/*! ./ms-file.module */ "./apps/ms-file/src/ms-file.module.ts");
const GlobalException_filter_1 = __webpack_require__(/*! libs/common/filters/GlobalException.filter */ "./libs/common/src/filters/GlobalException.filter.ts");
const common_1 = __webpack_require__(/*! @nestjs/common */ "@nestjs/common");
const config_1 = __webpack_require__(/*! ../config */ "./apps/ms-file/config/index.ts");
async function bootstrap() {
    const app = await core_1.NestFactory.create(ms_file_module_1.MsFileModule);
    app.useGlobalFilters(new GlobalException_filter_1.GlobalExceptionFilter());
    app.useGlobalPipes(new common_1.ValidationPipe());
    await app.listen(config_1.default.port);
    console.log(`${config_1.default.serviceName}:[http://127.0.0.1:${config_1.default.port}]`);
}
bootstrap();

})();

/******/ })()
;